import { IFeidaoAiNodejsComponent } from '@dfeidao/atom-nodejs/interfaces';
import nodejs from '@dfeidao/atom-nodejs/msg/nodejs';
import render from '@dfeidao/atom-nodejs/render/render';
import p001 from './p001';
import p002 from './p002';
import p004 from './p004';
import p005 from './p005';
import p003 from './p003';

export default async function na001(fd: IFeidaoAiNodejsComponent) {

	// todo
	const res = await nodejs<{ res: Array<{}>; c: number; }>(fd.data.actionid, fd.data.sessionid, 'risk_point/zj-000001/s001', { risk_po_type_name: '' });
	console.info(res);

	render(fd.data.node, res, p001, 'p001');
	render(fd.data.node, res[0], p004, 'p004');

	// //第一条
	const n = res[0] as { risk_po_type_no: string; risk_po_type_name: string };
	console.log("NNNNNNNNNN", n);

	const name = n.risk_po_type_no;
	const res1 = await nodejs<{ res: Array<{}>; c: number; }>(fd.data.actionid, fd.data.sessionid, 'risk_point/zj-000001/s003', { page_no: 1, risk_po_type_no: name });

	console.log("look=>", res1);

	if (res1.c > 0) {
		render(fd.data.node, res1.res, p002, 'p002');
		render(fd.data.node, res1.c, p003, 'p003');
	} else {
		render(fd.data.node, '', p005, 'p005');
	}



	console.info(res);
}
